home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Programmer Disk
/
The Programmer Disk (Microforum).iso
/
xpro
/
vc
/
pro3
/
dcir1.c
< prev
next >
Wrap
Text File
|
1993-06-10
|
5KB
|
156 lines
===========================================================================
BBS: The Abacus * HST/DS * Potterville, MI
Date: 06-04-93 (03:51) Number: 8
From: PEDRO DORIA MEUNIER Refer#: NONE
To: DAVID NUGENT Recvd: NO
Subj: MOV -> XOR 1/2 Conf: (37) C++ Langua
---------------------------------------------------------------------------
DN>Why not simply write the function in assembler and call it from your C++ code
Hope this helps you.
It is assumed you know how to plot a point in graphics mode using assembly.
It is also assumed that if you intend to use this code fragment in C you
know how to manipulate inline assembly and/or making the necessary steps
to making this an PUBLIC procedure and to specify the following variables
as EXTERNALs.
It uses the variables X, Y, Cw, Ck, Cradius
The Set_Pixel_XOR function first gets the screen contents at x,y coordinates
and then XORs it with the new contents
If you like me to send it please say so 'cause this message is ALREADY TOO
LONG...
Fellow Sysops, forgive me!...
Hope to hear from you soon,
Pedro Doria
;***************************************************************************
DrawCircle PROC FAR ;*
; Input : Cw *
; Ck (Cw and Ck being x,y coordinates of the center) *
; Cradius *
; Written by Pedro Doria Meunier (c) 1993 *
; *
; *
; It uses the Bresenham Algoritm *
;***************************************************************************
CStep1:
mov X, 0
mov ax, Cradius
mov Y, ax
mov ax, Y
mov bl, 2
mul bl
mov bx, 3
sub bx, ax
mov Cd, bx
jmp CStep4 ; Before all calculations we must plot
; the initial points so that the circle
; doesn't end up 'un'closed
CStep2:
mov cx, X
cmp cx, Y ; is x > y ?
jg CircleDone
CStep3:
cmp Cd, 0
jge CStep3_1
mov ax, X
mov bl, 4 ; d = d+4*x
mul bl
add ax, 6
add Cd, ax
inc X
jmp CStep4
CStep3_1:
mov cx, X
sub cx, Y
mov ax, cx ; d = d+4*(x-y)+10
mov bl, 4
imul bl
add Cd, ax
add Cd, 10
inc X
dec Y
CStep4:
mov cx, X
mov dx, Y
add cx, Cw
add dx, Ck
cmp XORFlag, 1
jne SHORT CStep4_1
call Set_Pixel_XOR
jmp SHORT CStep4_12
CStep4_1:
call Set_PIxel ; Plot (x+Cw, y+Ck)
CStep4_12:
mov cx, X
mov dx, Y
add dx, Cw
add cx, Ck
xchg cx, dx
cmp XORFlag, 1
jne SHORT CStep4_121
call Set_Pixel_XOR
jmp SHORT CStep4_13
CStep4_121:
call Set_Pixel ; Plot (y+Cw, x+Ck)
CStep4_13:
mov cx, X
mov dx, Y
neg dx
add dx, Cw
add cx, Ck
xchg cx, dx
cmp XORFlag, 1
jne SHORT CStep4_131
call Set_Pixel_XOR
jmp SHORT CStep4_14
CStep4_131:
call Set_Pixel ; Plot (-y+Cw, x+Ck)
CStep4_14:
mov cx, X
mov dx, Y
neg cx
add cx, Cw
add dx, Ck
cmp XORFlag, 1
jne SHORT CStep4_141
call Set_Pixel_XOR
jmp SHORT CStep4_15
CStep4_141:
call Set_Pixel ; Plot (-x+Cw, y+Ck)
CStep4_15:
mov cx, X
mov dx, Y
neg cx
add cx, Cw
neg dx
add dx, Ck
cmp XORFlag, 1
jne SHORT CStep4_151
call Set_Pixel_Xor
jmp SHORT CStep4_16
CStep4_151:
call Set_Pixel ; Plot (-x+Cw, -y+Ck)
CStep4_16:
mov cx, X
mov dx, Y
neg dx
add dx, Cw
neg cx
add cx, Ck
xchg cx, dx
cmp XORFlag, 1
jne SHORT CStep4_161
>>> Continued to next message
* SLMR 2.1a * MultiTask: Make twice the mistakes in ½ the time.